import React, { Component } from 'react';

class Home extends Component {
    constructor(props) {
        super(props)
        this.state = {
            flag: true
        }
    }
    ifShowFun = () => {
        console.log(this);
        if (this.state.flag) {
            return <div>已登录,欢迎进入此系统</div>
        } else {
            return <div>请登录</div>
        }
    }
    render() {
        let showHtml = this.state.flag ? <div>已登录,欢迎进入此系统</div> : <div>请登录</div>
        return (
            <div>
                <h2>条件渲染</h2>
                {this.state.flag ? <div>已登录,欢迎进入此系统</div> : <div>请登录</div>}
                {showHtml}
                {this.ifShowFun()}
            </div>
        );
    }
}

export default Home;